$(document).ready(function () {
    var invited_form = $(".invited_form");
    var h = "<div class='l_b fn-clear'>"
                +"<i class='fl icon_remove'>"
                 +" <img src='"+IMAGE_PATH+"remove.png'>"
                 +"<span class='line'></span>"
                +"</i>"
                +"<input type='text' class='input_text1'  name=''>"
                +"<p class='prompt'>例如：123@sina.com</p>"
              +"</div>"
    $(".icon_add").click(function(){
      $(".input_block").append(h);
      $(this).parents(".input_block").find(".input_text1:last").attr("name","email["+parseInt(100*Math.random())+"]")
        $('.input_text1').each(function () {
          $(this).rules('add', {
              email:true,
              messages:{email: "请填写正确的邮箱"}
          })
      });
      
    })

    invited_form.on("click",'.icon_remove',function(){
      $(this).parents('.l_b').remove();
    });



     $("#invited_form").validate({
         submitHandler: function (form) {
            oktipsoption = {
                type: 1,
                url: $('.formsub').attr('url'),
                msg: '发起成功'
            };
            ajaxform.init(oktipsoption, '.formsub');
            ajaxform.submit();
            // return false;
        //submit('',successcallback('修改成功,请重新登陆',$('.formsub').attr('tipurl')));
          },
          errorPlacement: function (error, element) {
              element.parents('.l_b').append(error);
              element.parents('.l_b').find('.prompt').hide();
          }
    });

      $('.input_text').each(function () {
        $(this).rules('add', {
            required: true,
            email:true,
            messages:{required:"请填写邮箱",email: "请填写正确的邮箱"}
        });
    });
})